import { _decorator, Button } from 'cc';
import { BasePopUp } from '../../../A-FRAME/component/ui.pop-up';
import { AudioMgr } from '../../../Mgr/AudioMgr';
import { GameMgr } from '../../../Mgr/GameMgr';
import { Url } from '../../../Tools/Url';
import { Popup } from '../page/popup';
const { ccclass, property } = _decorator;

@ccclass('RefreshPage')
export class RefreshPage extends BasePopUp<typeof Popup, { type: string, value: number }> {
    protected default_return: { type: string; value: number; };
    public onShow(...param: any[]): void {

        BasePopUp.jelly_enter(this.node);

    }
    protected _click_event_: { [name: string]: (this: RefreshPage, button: Button) => void; } = {
        contBtn(btn) {
            AudioMgr.ins.playOneShot(Url.AUDIO.SFX2, 1);
            btn.interactable = false;
            BasePopUp.jelly_leave(this.node).then(() => {
                GameMgr.ins.startTimer();
                this.close(null);
                btn.interactable = true;
            });
        },
        reBtn(btn) {
            AudioMgr.ins.playOneShot(Url.AUDIO.SFX2, 1);
            btn.interactable = false;
            GameMgr.ins.reStartGame();
            BasePopUp.jelly_leave(this.node).then(() => {
                this.close(null);
                btn.interactable = true;
            });
        },
        closeBtn(btn) {
            AudioMgr.ins.playOneShot(Url.AUDIO.SFX2, 1);
            btn.interactable = false;
            BasePopUp.jelly_leave(this.node).then(() => {
                GameMgr.ins.startTimer();
                this.close(null);
                btn.interactable = true;
            });
        }

    }
}

